package org.linlinjava.litemall.admin.web2.system;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.linlinjava.litemall.admin.service2.AdManagerService;
import org.linlinjava.litemall.core.util.R;
import org.linlinjava.litemall.db.domain.TAd;
import org.linlinjava.litemall.db.domain.TNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统设置
 */
@Api("系统设置-广告管理")
@RestController
@RequestMapping("/system/ad")
public class SystemAdController {

    @Autowired
    private AdManagerService adManagerService;

    @ApiOperation(value = "首页广告设置")
    @GetMapping("/adList")
    public Object adList() {
        return R.ok(adManagerService.adList());
    }

    @ApiOperation(value = "修改广告图片和启用状态", notes = "传id和img、enable")
    @PostMapping("/updateImg")
    public Object updateImg(@RequestBody TAd ad) {
        return R.ok(adManagerService.updateImg(ad));
    }

    @ApiOperation(value = "全网通告设置")
    @GetMapping("/noticeList")
    public Object noticeList() {
        return R.ok(adManagerService.noticeList());
    }

    @ApiOperation(value = "添加通告", notes = "传content")
    @PostMapping("/addNotice")
    public Object addNotice(@RequestBody TNotice notice) {
        return R.ok(adManagerService.addNotice(notice));
    }

    @ApiOperation(value = "删除通告", notes = "传id")
    @PostMapping("/delNotice")
    public Object delNotice(@RequestBody TNotice notice) {
        return R.ok(adManagerService.delNotice(notice));
    }



}
